<?php

namespace app\admin\model\bill;

use think\Model;


class Bill extends Model
{





    // 表名
    protected $table = 'shopro_order_bill';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'status_text',
        'coupon_status_text',
        'comfirm_status_text',
        'goods_type_text'
    ];



    public function getTypeList()
    {
        return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getCouponStatusList()
    {
        return ['0' => __('Coupon_status 0'), '1' => __('Coupon_status 1')];
    }

    public function getComfirmStatusList()
    {
        return ['0' => __('Comfirm_status 0'), '1' => __('Comfirm_status 1')];
    }

    public function getGoodsTypeList()
    {
        return ['5' => __('Goods_type 5'), '2' => __('Goods_type 2'), '1' => __('Goods_type 1'), '6' => __('Goods_type 6')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCouponStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['coupon_status']) ? $data['coupon_status'] : '');
        $list = $this->getCouponStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getComfirmStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['comfirm_status']) ? $data['comfirm_status'] : '');
        $list = $this->getComfirmStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGoodsTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['goods_type']) ? $data['goods_type'] : '');
        $list = $this->getGoodsTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
